import React, {useEffect, useState} from 'react';
import {useNavigate, useParams} from "react-router-dom";
import axios from "axios";

function Index(props) {
    const navigate = useNavigate()
    const {id} = useParams()
    console.log(id)
    const [item,setItem] = useState([])
    useEffect(()=>{
        axios.get(`https://api.github.com/users/${id}`).then(({data})=>{
            console.log(data)
            setItem(data)
        })
    },[])
    return (
        <div>
            <h3>详情页</h3>
            <button onClick={()=>navigate(-1)}>点击返回列表</button>
            <h2><a href={item.html_url}>{item.name}的git主页</a></h2>
            <img src={item.avatar_url} alt=""/>
        </div>
    );
}

export default Index;